package com.chenchao.javainnerclass;

import java.util.Scanner;

/**
 * @encoding : UTF-8
 * @Time : 2020/11/10 20:39
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.javainnerclass.Enumerate.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 * 枚举,一个特殊的类,表示一个事物固定状态
 * 枚举的构造器被私有化，无法在外面创建新对象
 */
enum WeekDayEnum{
    MONDAY, TUESDAY , WENDESDAY, FRIDAY, SATURDAY, SUNDAY;
}
public class Enumerate {
    public static void main(String[] args) {
        System.out.println(args.length);
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入星期几");
        String weekDay= scanner.nextLine();
        int weekDaynum=scanner.nextInt();
        scanner.close();
        System.out.println(WeekDayEnum.TUESDAY);

        //ordinal()获得当前对象的下标
        System.out.println(WeekDayEnum.TUESDAY.ordinal());

        //name()/toString()获得当前对象的名字（String）
        System.out.println(WeekDayEnum.TUESDAY.name());
        System.out.println(WeekDayEnum.TUESDAY.toString());
        System.out.println("++++++++++++");

        //valueOf（）通过名字（String）获得对象
        WeekDayEnum weekDayEnum=WeekDayEnum.valueOf(weekDay);
        //values()获得对象数组
        WeekDayEnum weekDayEnum2=weekDayEnum.values()[weekDaynum/7];
        //遍历对象数组
        for (WeekDayEnum value : WeekDayEnum.values()) {
            System.out.println(value);
        }
        switch (weekDayEnum){
            case MONDAY:case TUESDAY:case WENDESDAY: case FRIDAY:{
                System.out.println("上课");
            }break;
            case SATURDAY: case SUNDAY:{
                System.out.println("休息");
            }break;
        }
    }

}
